﻿using System;
using LimitatorInterfaces.CorrectServices;

namespace CorrectServices
{
    public class GoCorrectionParser : ICorrectionParser
    {
        public CorrectionLimitEntity ParceFrom(object param)
        {
            if (param == null) throw new ArgumentNullException("param");

            var row = param as object[];

            if ((row == null) || (row.Length != 2) ||
                (string.IsNullOrWhiteSpace(row[0] as string)))
                return null;

            decimal value = 0;

            if (row[1] == null || row[1].GetType() != typeof(decimal))
                return null;

            value = (decimal)row[1];

            return new CorrectionLimitEntity { ClientCode = row[0].ToString(), Value = value, ActiveCode = "Money", TradeSystem = "Micex", IsMoney = true };
        }
    }
}